"""
    消息队列, 先进先出原则
"""

from multiprocessing import Queue, Process
from random import randint
import os
from time import sleep

# 实例化消息队列
q = Queue()

def handle_new():
    for i in range(6):
        x = randint(1, 33)  # 1到33随机一个
        q.put(x)  # 写入消息队列
    q.put(randint(1, 16))  # 1到16 随机一个写入队列


def request_new():
    li = []
    for i in range(6): # 获取前6个蓝球
        li.append(q.get())
    li.sort()  # 排序
    
    li.append(q.get())  # 获取第7个红球
    print(li)
    

ls = [handle_new, request_new]
lie = []

for i in ls:
    so = Process(target=i)
    so.start()
    lie.append(i)
    so.join()
[so.join() for i in lie]
